package com.viviet.mobileservices.dao.impl;
// default package

import java.util.List;

import org.hibernate.LockMode;

import com.viviet.mobileservices.dao.IVMQrCodeDAO;
import com.viviet.mobileservices.dao.entity.VMCustomer;
import com.viviet.mobileservices.dao.entity.VMQrCode;
import com.viviet.mobileservices.util.Logit;

/**
 * A data access object (DAO) providing persistence and search support for
 * BoCustomer entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see .VMCustomer
 * @author MyEclipse Persistence Tools
 */

public class VMQrCodeDAO extends BaseHelperDAO implements IVMQrCodeDAO {
	private static final Logit log = Logit.getInstance(VMQrCodeDAO.class);
	
	public void save(VMQrCode transientInstance) {
		log.debug("saving VMQrCode instance");
		try {
			getHibernateTemplate().saveOrUpdate(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(VMQrCode persistentInstance) {
		log.debug("deleting VMQrCode instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public VMQrCode findById(java.lang.String id) {
		log.debug("getting VMQrCode instance with id: " + id);
		try {
			VMQrCode instance = (VMQrCode) getHibernateTemplate().get("com.viviet.mobileservices.dao.entity.VMQrCode", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding VMQrCode instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from VMQrCode as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	
	public List findAll() {
		log.debug("finding all VMQrCode instances");
		try {
			String queryString = "from VMQrCode";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public VMQrCode merge(VMQrCode detachedInstance) {
		log.debug("merging VMQrCode instance");
		try {
			VMQrCode result = (VMQrCode) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(VMQrCode instance) {
		log.debug("attaching dirty VMQrCode instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}